Clear[n,fs];
f[x_]:=Piecewise[{{-1,-Pi<x<0},{1,0<x<Pi}}];fourierseries=RecurrenceTable[{fs[n]==2 Re[FourierCoefficient[f[x],x,n]]Cos[n x] -2 Im[FourierCoefficient[f[x],x,n]] Sin[n x]+fs[n-1], fs[0]==FourierCoefficient[f[x],x,0]},fs,{n,0,30}];ListAnimate[Table[Plot[{f[x],fourierseries[[n]]},{x,-Pi,Pi},PlotRange->{{-Pi-0.1,Pi+0.1},{-1.75,1.75}}],{n,0,30}]]

Clear[n,fs];
f[x_]:=Abs[x];
g[x_]:=Piecewise[{{Abs[x+2Pi],-2Pi<x<-Pi},{Abs[x],-Pi<x<Pi},{Abs[x-2Pi],Pi<x<2Pi}}];fourierseries=+RecurrenceTable[{fs[n]==2 Re[FourierCoefficient[f[x],x,n]]Cos[n x] -2 Im[FourierCoefficient[f[x],x,n]] Sin[n x]+fs[n-1], fs[0]==FourierCoefficient[f[x],x,0]},fs,{n,0,30}];ListAnimate[Table[Plot[{g[x],fourierseries[[n]]},{x,-2Pi-1,2Pi+1},PlotRange->{{-2Pi-0.1,2Pi+0.1},{-0.1,Pi+1}}],{n,0,10}]]

Clear[n,fs];
f[x_]:=Cos[Pi x];fourierseries=RecurrenceTable[{fs[n]==2 Re[FourierCoefficient[f[x],x,n]]Cos[n x] -2 Im[FourierCoefficient[f[x],x,n]] Sin[n x]+fs[n-1], fs[0]==FourierCoefficient[f[x],x,0]},fs,{n,0,10}];ListAnimate[Table[Plot[{f[x],fourierseries[[n]]},{x,-Pi,Pi},
PlotRange->{{-Pi+0.2,Pi-0.2},{-1.5,1.5}}],{n,0,10}]]

Clear[n,fs];
g[x_]:=Piecewise[{{(x+2Pi)^2,-3Pi/2<x<-Pi},{x^2,-Pi<x<Pi},{(x-2Pi)^2,Pi<x<3Pi/2}}];
f[x_]:=x^2;fourierseries=RecurrenceTable[{fs[n]==2 Re[FourierCoefficient[f[x],x,n]]Cos[n x] -2 Im[FourierCoefficient[f[x],x,n]] Sin[n x]+fs[n-1], fs[0]==FourierCoefficient[f[x],x,0]},fs,{n,0,50}];ListAnimate[Table[Plot[{g[x],fourierseries[[n]]},{x,-3Pi/2,3Pi/2},PlotRange->{{-3Pi/2,3Pi/2},{-0.1,1.1 Pi^2}}],{n,0,50}]]

Clear[n,fs];
f[x_]:=Piecewise[{{-2,-Pi<x<0},{2,0<x<Pi}}];fourierseries=RecurrenceTable[{fs[n]==2 Re[FourierCoefficient[f[x],x,n]]Cos[n x] -2 Im[FourierCoefficient[f[x],x,n]] Sin[n x]+fs[n-1], fs[0]==FourierCoefficient[f[x],x,0]},fs,{n,0,30}];ListAnimate[Table[Plot[{f[x],fourierseries[[n]]},{x,-Pi,Pi},PlotRange->{{-Pi-0.1,Pi+0.1},{-2.75,2.75}}],{n,0,30}]]

Clear[n,fs];
g[x_]:=Piecewise[{{x+2Pi,-3Pi/2<x<-Pi},{x,-Pi<x<Pi},{x-2Pi,Pi<x<3Pi/2}}];
f[x_]:=x;fourierseries=RecurrenceTable[{fs[n]==2 Re[FourierCoefficient[f[x],x,n]]Cos[n x] -2 Im[FourierCoefficient[f[x],x,n]] Sin[n x]+fs[n-1], fs[0]==FourierCoefficient[f[x],x,0]},fs,{n,0,30}];ListAnimate[Table[Plot[{g[x],fourierseries[[n]]},{x,-3Pi/2,3Pi/2},PlotRange->{{-3Pi/2,3Pi/2},{-3.5,3.5}}],{n,0,30}]]

Clear[n,fs];
g[x_]:=Abs[Sin[ x]];
f[x_]:=Piecewise[{{-Sin[x],-Pi<x<0},{Sin[x],0<x<Pi}}];fourierseries=RecurrenceTable[{fs[n]==2 Re[FourierCoefficient[f[x],x,n]]Cos[n x]-2 Im[FourierCoefficient[f[x],x,n]] Sin[n x] +fs[n-1], fs[0]==FourierCoefficient[f[x],x,0]},fs,{n,0,10}];ListAnimate[Table[Plot[{f[x],fourierseries[[n]]},{x,-Pi,Pi},PlotRange->{{-Pi-0.1,Pi+0.1},{-0.1,1.5}}],{n,0,10}]]